<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
        // document.onmousemove = function (ev) {
        //     var eee = ev || window.event;
        //     var div = document.getElementById('div');
        //     div.innerHTML = "clientX: " + eee.clientX + ",clientY:" + eee.clientY +
        //         "</br> screenX:" + eee.screenX + ",screenY:" + eee.screenY;
        // }

        function test(ev) {
            var e = ev || window.event;
            var div1 = document.getElementById('div1');
            div1.innerHTML = "offsetX:" + e.offsetX + ",offsetY : " + e.offsetY;
        }

    </script>
</head>

<body>
    <div id="div1" class="container"></div>
    <input type="button" value="test" onclick="test()">
</body>

<style>
    * {
        padding: 0;
        margin: 0;
    }

    .container {
        width: 200px;
        height: 100px;
        border: 1px solid #c00;
    }

    input[type="button"] {
        margin: 50px;
        border: none;
        width: 100px;
        height: 50px;
        background: green;
    }

    /* clientX是鼠标相对以浏览器有效区域的的X轴坐标， */
    /* clientY是鼠标相对以浏览器有效区域的的Y轴坐标， */
</style>

</html>